package com.qf.test3;

import org.junit.Test;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

/**
 * 连接池操作
 * @author zjw
 * @description
 * @date 2021/10/29 17:42
 */
public class DemoTest {

    @Test
    public void test() {
        //1. 构建连接池
        JedisPool pool = new JedisPool("192.168.41.41",6379);

        Jedis jedis = null;
        try {
            //2. 从连接池获取连接对象
            jedis = pool.getResource();

            //3. 操作
            System.out.println(jedis.get("user"));
        } finally {
            //4. 归还连接对象
            jedis.close();
        }
    }

}
